import Mock from 'mockjs'

let allUserData = {
    admin: {
        menuData: [
            {
                path: '/home',
                name: 'home',
                label: '首页',
                icon: 's-home',
                url: 'Home.vue'
            },
            {
                path: '/mall',
                name: 'mall',
                label: '商品管理',
                icon: 'video-play',
                url: 'Mall.vue'
            },
            {
                path: '/user',
                name: 'user',
                label: '用户管理',
                icon: 'user',
                url: 'User.vue'
            },
            {
                label: '其他',
                icon: 'location',
                children: [
                    {
                        path: '/page1',
                        name: 'page1',
                        label: '页面1',
                        icon: 'setting',
                        url: 'PageOne.vue'
                    },
                    {
                        path: '/page2',
                        name: 'page2',
                        label: '页面2',
                        icon: 'setting',
                        url: 'PageTwo.vue'
                    },
                ]
            }
        ],
        token: Mock.Random.guid(),
        message: 'success'
    },
    xiaoxiao: {
        token: Mock.Random.guid(),
        menuData: [
            {
                path: '/home',
                name: 'home',
                label: '首页',
                icon: 's-home',
                url: 'Home.vue'
            },
            {
                path: '/mall',
                name: 'mall',
                label: '商品管理',
                icon: 'video-play',
                url: 'Mall.vue'
            }
        ]
    }
}


export default {
    getMenu: config => {
        const {username, password} = config

        //先判断用户是否存在，
        //判断账号和密码是否对应
        if (username === 'admin' && password === 'admin') {
            return {
                code: 20000,
                data:allUserData.admin
            }
        } else if (username === 'xiaoxiao' && password === 'xiaoxiao') {
            return {
                code: 20000,
                data:allUserData.xiaoxiao
            }
        } else {
            return {
                code: -999,
                data: {
                    message: 'error'
                }
            }
        }
    },
    logout: () => {

        return {
            code: 20000,
            data: {

                message: 'success'
            }
        }
    }

}
